'use strict';
/** 商场系统 */
module.exports.run = function(d,s){
    const bs = require("../module/base"), shopitem = require("../config/shop" + s.U.gamename), bag = require("./bag");
    switch(d[1]){
        case 1:{ //获取商城列表
            break;
        }case 2:{ //购买
            if(!bs.checkParam(["id", "num"], d)) return;
            if(!(d[2].id in shopitem)) return bs.sendE(s, 11);
            let item = shopitem[d[2].id];
            //判断道具是否够
            if(s.U.bag[item.pay] < item.paynum){
                if(item.pay == 1) return bs.sendE(s, 12);
                else if(item.pay == 2) return bs.sendE(s, 13);
                return bs.sendE(s, 4);
            }
            //扣除道具
            bag.add([[item.pay, -item.paynum]], s, null, 9, d[2].id);
            //获得道具
            bag.add(item.item, s, null, 9, d[2].id);

            bs.send(s, d);
            break;
        }
    }
}